﻿namespace PlaylistCopy.Extensions
{
    using CuttingEdge.Conditions;
    using System.Collections.Generic;
    using System.Linq;

    public static class FileExtensionExtensions
    {
        public static string ToDialogFilterExpression(this IEnumerable<string> collection)
        {
// ReSharper disable once PossibleMultipleEnumeration
            Condition.Requires(collection, "collection").IsNotNull();

// ReSharper disable once PossibleMultipleEnumeration
            return string.Join("|",
                               collection.Select(extension => "*." + extension)
                                         .Select(extension => string.Format("{0}|{1}", extension, extension)));
        }
    }
}
